#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <iostream>
#include <string.h>
#include <arpa/inet.h>

using namespace std;

static char* GetHostName(char* addr);

static char* GetHostName(char* addr){

  cout<< addr << endl;
  //creation of parameters
  struct sockaddr_in address;
  bzero(&address, sizeof(address));
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = inet_addr(addr);
  char host[1025] = "";
  char server[32];
  int flags = 0;


  if(getnameinfo((struct sockaddr *)&address, sizeof(struct sockaddr), host, sizeof(host), server, sizeof(server), flags)!= 0){
    cout<< "Error finding hostname." << endl;
  }
  else{

  cout<< host << endl;
  cout<< server << endl;
  }

}

int main(){
  GetHostName("74.42.59.193");

}
